package br.com.cept.sce.dao;

import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction;

import br.com.cept.sce.commons.util.DAOManager;
import br.com.cept.sce.dominio.impl.Log;
import br.com.cept.sce.exception.manterLog.LogException;

public class LogDAO {
	
	public void salvarLog(Log log)throws LogException{
		EntityManager entityManager = DAOManager.getEntityManager();
		EntityTransaction transaction = entityManager.getTransaction();		
		try{
			transaction.begin();
			entityManager.persist(log);
			transaction.commit();
			entityManager.close();
		}catch(Exception erro){
			transaction.rollback();
			erro.printStackTrace();
			throw new LogException();
		}		
	}

}
